<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 14-10-15
 * Time: 下午3:05
 * @author 郑钟良<zzl@ourstu.com>
 */

namespace Question\Model;


use Think\Model;

class QuestionRepostModel extends Model{
    protected $tableName = 'question';
    protected $_auto = array(
        array('create_time', NOW_TIME, self::MODEL_INSERT),
        array('update_time', NOW_TIME, self::MODEL_UPDATE),
        array('status', '1', self::MODEL_INSERT),
        array('is_repost','1',self::MODEL_INSERT),
    );
    protected $_validate = array(
        array('content', '1,200', '内容不能为空', self::MUST_VALIDATE, 'length')
    );
    protected $insertField = 'content,answer_num,type,is_repost,last_question_id,first_question_id,share_num,repost_num'; //新增数据时允许操作的字段
    protected $updateField = 'content,answer_num,type,is_repost,last_question_id,first_question_id,share_num,repost_num'; //编辑数据时允许操作的字段

    /**创建转发
     * @param array $data
     * @return bool|mixed
     * @author 郑钟良<zzl@ourstu.com>
     */
    public function createQuestion($data=array()){
        $data=$this->create($data);
        if (!$data) return false;
        return $this->add($data);
    }
} 